/*******************************************************************************
 * @file    ringfifo.h
 * @brief   A implementation of FIFO buffer
 * Description: Buffer data is an array from external input
 *
 * @version 1.0.0
 *******************************************************************************
 * @license Refer License or other description Docs
 * @author  Felix
 ******************************************************************************/
#ifndef UTILS_RINGFIFO_H
#define UTILS_RINGFIFO_H

#include <stdint.h>

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus */

typedef struct {
    uint8_t* buf;
    uint16_t size;
    uint16_t wr;
    uint16_t rd;
} ringbuf_t;

void RINGBUF_Init(ringbuf_t* rb, uint8_t* buf, uint16_t size);
int  RINGBUF_Put(ringbuf_t* rb, uint8_t* buf, uint16_t size);
int  RINGBUF_Peek(ringbuf_t* rb, uint8_t** buf);
int  RINGBUF_Poll(ringbuf_t* rb, uint16_t size);

#if defined(__cplusplus)
}
#endif /* __cplusplus */

#endif
